package kl.orderReturn;

import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

@Slf4j
public class MyCalculator {

    public static void main(String[] args) {
        Integer quantity = 1;
        BigDecimal csuOrderPrice = new BigDecimal("0.00");
        BigDecimal itemCouponAmount = new BigDecimal("0.00");

        BigDecimal diffItemAmount = new BigDecimal("0.00");

        Integer returnQuantity = 0;
        BigDecimal returnCouponAmount =  new BigDecimal("0.00");
        BigDecimal giftCouponAmount = new BigDecimal("0.00");

        Integer realPurchaseQuantity = 0;
        Integer purchasingQuantity = 0;


        BigDecimal amount = new BigDecimal(quantity).multiply(csuOrderPrice).add(diffItemAmount)
                .subtract(new BigDecimal(returnQuantity).multiply(csuOrderPrice))
                .subtract(new BigDecimal(realPurchaseQuantity).multiply(csuOrderPrice))
                .subtract(new BigDecimal(purchasingQuantity).multiply(csuOrderPrice));

        BigDecimal couponAmount = itemCouponAmount.subtract(returnCouponAmount.add(giftCouponAmount))
                .subtract(new BigDecimal(realPurchaseQuantity).multiply(itemCouponAmount)
                        .divide(new BigDecimal(quantity), 2, BigDecimal.ROUND_DOWN))
                .subtract(new BigDecimal(purchasingQuantity).multiply(itemCouponAmount)
                        .divide(new BigDecimal(quantity), 2, BigDecimal.ROUND_DOWN));
        log.info("包含优惠的商品金额:{}", amount);
        log.info("优惠金额:{} 扣除优惠金额后的小计:{}", couponAmount, amount.subtract(couponAmount));
    }
}
